$(document).ready(function () {
  setTimeout(function () {
    requirejs.config({
      baseUrl: "src",
      paths: {
        jquery: "../public/js/jquery.min",
        underscore: "../public/js/underscore-min",
        backbone: "../public/js/backbone-min",
      },
    });

    const LOADNAV_URL = "/api/nav";
    nav.loadNav(LOADNAV_URL, $(".layui-nav")).then(function () {
      layui.use("element", function () {
        var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块

        element.render("nav");

        //监听导航点击
        element.on("nav(demo)", function (elem) {
          console.log(elem);
          layer.msg(elem.text());
        });
      });
      if (window.location.hash == "") window.location.hash = "#/";
      $('a[href="' + window.location.hash + '"')
        .parent()
        .addClass("layui-this");
    });
  }, 500);
});
